package xj.graph2d.template;

import xj.graph2d.DrawShape;
import xj.graph2d.DrawShapeConstants;
import xj.lang.CodeWriter;

public class TemplateToolButton {

  public static final int TOOL_PANEL_BUTTON = 0;
  public static final int POPUP_BUTTON = 1;

  public static final int DEFAULT_TOOL = 0;
  public static final int SCALE_TOOL = 1;
  public static final int ONE_POINT_TOOL = 2;

  public TemplateToolButton(String name, DrawShape shape) {
    this(name, shape, shape, 24, 24, false, true, 
	 DEFAULT_TOOL, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, int width, int height) {
    this(name, shape, shape, width, height, false, true, 
	 DEFAULT_TOOL, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, int width, int height,
			    boolean selected) {
    this(name, shape, shape, width, height, selected, true, 
	 DEFAULT_TOOL, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, int width, int height,
			    boolean selected, boolean enabled) {
    this(name, shape, shape, width, height, selected, enabled, 
	 DEFAULT_TOOL, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, DrawShape iconShape, int width,
			    int height, boolean selected, boolean enabled) {
    this(name, shape, iconShape, width, height, selected, enabled,
	 DEFAULT_TOOL, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, 
			    int width, int height,
			    boolean selected, boolean enabled, 
			    int toolType) {
    this(name, shape, shape, width, height, selected, enabled, 
	 toolType, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, 
			    int width, int height,
			    boolean selected, boolean enabled, 
			    int toolType, int buttonType) {
    this(name, shape, shape, width, height, selected, enabled, 
	 toolType, false, buttonType);
  }

  public TemplateToolButton(String name, DrawShape shape, 
			    int width, int height,
			    boolean selected, boolean enabled, 
			    int toolType, boolean reverseEnds, 
			    int buttonType) {
    this(name, shape, shape, width, height, selected, enabled, 
	 toolType, reverseEnds, buttonType);
  }

  public TemplateToolButton(String name, DrawShape shape, DrawShape iconShape, 
			    int width, int height, boolean selected, boolean enabled, 
			    int toolType) {
    this(name, shape, shape, width, height, selected, enabled, 
	 toolType, false, TOOL_PANEL_BUTTON);
  }

  public TemplateToolButton(String name, DrawShape shape, DrawShape iconShape, 
			    int width, int height, boolean selected, boolean enabled, 
			    int toolType, int buttonType) {
    this(name, shape, shape, width, height, selected, enabled, 
	 toolType, false, buttonType);
  }

  public TemplateToolButton(String name, DrawShape shape, DrawShape iconShape, 
			    int width, int height, boolean selected, boolean enabled, 
			    int toolType, boolean reverseEnds, int buttonType) {
    this.name = name;
    this.shape = shape;
    this.iconShape = iconShape;
    this.width = width;
    this.height = height;
    this.selected = selected;
    this.enabled = enabled;
    this.toolType = toolType;
    this.reverseEnds = reverseEnds;
    this.buttonType = buttonType;
  }

  public TemplateToolButton(String name, String protoName, DrawShape iconShape, 
			    int width, int height, boolean selected, boolean enabled, 
			    int toolType, boolean reverseEnds, int buttonType) {
    this.name = name;
    this.protoName = protoName;
    this.iconShape = iconShape;
    this.width = width;
    this.height = height;
    this.selected = selected;
    this.enabled = enabled;
    this.toolType = toolType;
    this.reverseEnds = reverseEnds;
    this.buttonType = buttonType;
  }


  public void write(CodeWriter cout) {
    if (cout != null && shape != null) {
      cout.println("<ShapeButton name=\"" + name + "\" width=\"" + width + 
		   "\" height=\"" + height + "\" selected=\"" + selected + 
		   "\" enabled=\"" + enabled + "\">");
      cout.thisIndentInc();
      shape.writeXML(cout, DrawShapeConstants.WRITE_XML_DEFAULT, null);
      cout.thisIndentDec();
      cout.println("</ShapeButton>");
    }
  }

  public String name;

  public String protoName;

  public DrawShape shape;

  public DrawShape iconShape;

  public int width;

  public int height;

  public boolean selected;

  public boolean enabled;

  public int toolType;

  public boolean reverseEnds;

  public int buttonType;

}
